package com.mobile.business;

import java.io.File;
import java.util.List;

import com.mobile.dao.grid.base.spring.BaseSpringDAOImpl;
import com.mobile.model.SoftwareInfo;
import com.mobile.struts.form.SoftwareInfoForm;
import com.mobile.tools.BeanUtil;
import com.mobile.tools.SystemConfig;

public class SoftwareInfoBusiness  
			extends BaseBusiness 
			implements ISoftwareInfoBusiness{
	private SystemConfig systemConfig;
	public void setSystemConfig(SystemConfig systemConfig) {
		this.systemConfig = systemConfig;
	}

	public String save(Object o){
		for(int i=0;i<50;i++){
			SoftwareInfo si=new SoftwareInfo();
			si.setSoftwareTitle("火狐"+i);
			si.setSoftwareName("火狐"+i);
			si.setSoftwareSrc("火狐SRC"+i);
			baseDAO.save(si);
		}
		return null;
	}
	
	public void saveSoftwareInfo(SoftwareInfoForm form){
		SoftwareInfo softwareInfo=new SoftwareInfo();
		BeanUtil.copyProperties(softwareInfo,form);
		softwareInfo.setSoftwareSrc(systemConfig.getUploadPath()+File.separator+form.getFile().getFileName());
		baseDAO.save(softwareInfo);
	}
	
	public List<SoftwareInfo> findList(){
		return (List<SoftwareInfo>)baseDAO.getObjectsByIds(new SoftwareInfo(), 0, 10);
	}

	public void setBaseDAO(BaseSpringDAOImpl baseDAO) {
		this.baseDAO = baseDAO;
	}
}
